package com.yxp.webtest.bean;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.PriorityOrdered;

@Slf4j
public class BeanPostProcessSecondPojo implements BeanPostProcessor, BeanFactoryPostProcessor, PriorityOrdered {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        log.info(this.getClass().getSimpleName() + " invoke postProcessBeforeInitialization " + beanName + " " + bean.getClass().getName());
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        log.info(this.getClass().getSimpleName() + " invoke postProcessAfterInitialization " + beanName + " " + bean.getClass().getName());
        return bean;
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        log.info(this.getClass().getSimpleName() + " invoke postProcessBeanFactory");
    }

    @Override
    public int getOrder() {
        return 1;
    }
}
